package com.hlt.shuiliting.dao;

import java.util.List;
import java.util.Map;

import com.hlt.shuiliting.database.DBUtil;
import com.hlt.shuiliting.valuebean.CanJianQY;

public class CanJianQYDAO {
	
	private int updateCount;
	
	public List list(int GongChengXMID) {
		String sql = "select * from CanJianQY where GongChengXMID = ?";
		Object[] params = {GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		
		return list;
	}
	
	public Map view(int id) {
		List list = null;
		String sql = "select * from CanJianQY where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		list = myDB.getResultSet();
		Map map = (Map)list.get(0);
		
		return map;
	}
	public int insert(CanJianQY canJianQY) {
		String sql = "insert CanJianQY values (seq_CanJianQY.nextVal, ?, to_date('?','yyyy-mm-dd'), ?,?, ?, ?, ?,?, ?, to_date('?','yyyy-mm-dd'), ?,?)";
		String ZhuangTai = canJianQY.getZhuangTai();
		String JiLuSJ = canJianQY.getJiLuSJ();
		String LuRuR = canJianQY.getLuRuR();
		String CanJianDWMC = canJianQY.getCanJianDWMC();
		String ZeRenLX = canJianQY.getZeRenLX();
		String XiangMuFZR = canJianQY.getXiangMuFZR();
		String JiShuFZR = canJianQY.getJiShuFZR();
		String FuZeXMZYSX = canJianQY.getFuZeXMZYSX();
		String GongHuoZYSBMS = canJianQY.getGongHuoZYSBMS();
		String JiaoHuoRQ = canJianQY.getJiaoHuoRQ();
		int GongChengXMID = canJianQY.getGongChengXMID();
		int QiYeID = canJianQY.getQiYeID();
		Object[] params = {ZhuangTai, JiLuSJ, LuRuR, CanJianDWMC, ZeRenLX, XiangMuFZR, JiShuFZR, FuZeXMZYSX, GongHuoZYSBMS, JiaoHuoRQ, GongChengXMID, QiYeID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int update(CanJianQY canJianQY) {
		String sql = "update CanJianQY set ZhuangTai = ?, JiLuSJ = to_date('?','yyyy-mm-dd'), LuRuR = ?, CanJianDWMC = ?, ZeRenLX = ?," +
				" XiangMuFZR = ?, JiShuFZR = ?, FuZeXMZYSX = ?, GongHuoZYSBMS = ?, JiaoHuoRQ = to_date('?','yyyy-mm-dd'), GongChengXMID = ?, QiYeID = ?, where ID = ?";
		int ID = canJianQY.getID();
		String ZhuangTai = canJianQY.getZhuangTai();
		String JiLuSJ = canJianQY.getJiLuSJ();
		String LuRuR = canJianQY.getLuRuR();
		String CanJianDWMC = canJianQY.getCanJianDWMC();
		String ZeRenLX = canJianQY.getZeRenLX();
		String XiangMuFZR = canJianQY.getXiangMuFZR();
		String JiShuFZR = canJianQY.getJiShuFZR();
		String FuZeXMZYSX = canJianQY.getFuZeXMZYSX();
		String GongHuoZYSBMS = canJianQY.getGongHuoZYSBMS();
		String JiaoHuoRQ = canJianQY.getJiaoHuoRQ();
		int GongChengXMID = canJianQY.getGongChengXMID();
		int QiYeID = canJianQY.getQiYeID();
		Object[] params = {ZhuangTai, JiLuSJ, LuRuR, CanJianDWMC, ZeRenLX, XiangMuFZR, JiShuFZR, FuZeXMZYSX, GongHuoZYSBMS, JiaoHuoRQ, GongChengXMID, QiYeID, ID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int delete(int id) {
		String sql = "delete from CanJianQY where ID = ?";
		Object[] params = {};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}

}
